﻿using System;
using System.Text;

namespace Wosperry.ExpressionExtensions
{
    /// <summary>
    /// 查询参数特性（由于子特性较多，暂时放一个文件）
    /// </summary>
    /// <remarks>
    /// 允许给属性添加，允许多次添加，不可继承
    /// </remarks>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
    public class BuildWhereAttribute : Attribute
    {
        /// <summary>
        /// 实体属性名
        /// </summary>
        public string Field { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="field">字段名，不指定时与入参名一致</param>
        public BuildWhereAttribute(string field = "")
        {
            Field = field;
        }
    }

    /// <summary>
    /// 相等
    /// </summary>
    public class WhereEqualAttribute : BuildWhereAttribute
    {
        /// <summary>
        /// 相等
        /// </summary>
        /// <param name="field">对比字段</param>
        public WhereEqualAttribute(string field = null) : base(field) { }
    }

    /// <summary>
    /// 大于
    /// </summary>
    public class WhereLargerAttribute : BuildWhereAttribute
    {
        /// <summary>
        /// 大于
        /// </summary>
        /// <param name="field">对比字段</param>
        public WhereLargerAttribute(string field = null) : base(field) { }
    }

    /// <summary>
    /// 大于等于
    /// </summary>
    public class WhereLargerEqualAttribute : BuildWhereAttribute
    {
        /// <summary>
        /// 大于等于
        /// </summary>
        /// <param name="field">对比字段</param>
        public WhereLargerEqualAttribute(string field = null) : base(field) { }
    }

    /// <summary>
    /// 小于
    /// </summary>
    public class WhereSmallerAttribute : BuildWhereAttribute
    {
        /// <summary>
        /// 小于
        /// </summary>
        /// <param name="field">对比字段</param>
        public WhereSmallerAttribute(string field = null) : base(field) { }
    }

    /// <summary>
    /// 小于等于
    /// </summary>
    public class WhereSmallerEqualAttribute : BuildWhereAttribute
    {
        /// <summary>
        /// 小于等于
        /// </summary>
        /// <param name="field">对比字段</param>
        public WhereSmallerEqualAttribute(string field = null) : base(field) { }
    }

    /// <summary>
    /// 相似
    /// </summary>
    public class WhereLikeAttribute : BuildWhereAttribute
    {
        /// <summary>
        /// 相似
        /// </summary>
        /// <param name="field">对比字段</param>
        public WhereLikeAttribute(string field = null) : base(field) { }
    }
}
